import request from '@/utils/request'
import _ from "lodash";
const path = require('path')
const files = require.context('.', true, /\.js/)
const modules = {}
files.keys().forEach(key => {
    const name = path.basename(key, '.js')
    if(name === 'index'){ return; }
    modules[name] = files(key).default || files(key)
})

//
_.api = function(name,options = {}){
    let fun = _.get(modules,name);
    //
    options = Object.assign({
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
        },
        responseType:'json',
        method: 'get',
        url: ''
    },fun(options));
    //
    return request(options)
}
